<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .container {
      width: 1000px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }

    .box {
      width: 800px;
      height: 240px;
      margin: 0 auto;
      margin-top: 40px;
      clear: both;
    }

    #btn {
      width: 160px;
      height: 60px;
      margin-top: 50px;
      font-size: 24px;
    }

    .name {
      width: 180px;
      height: 60px;
      float: left;
      background-color: #eee;
      margin-left: 10px;
      margin-top: 10px;
      text-align: center;
      line-height: 60px;
    }
    h1 {
      text-align: center;
    }
  </style>

</head>

<body>
  <div class="container">
  <h1>XXX抽饭系统</h1>
  <span id="span"></span>
  <div class="box" id="box"></div>
  <input type="button" id="btn" value="点击" /></div>
  <script type="text/javascript">
    var arrs = ['糖醋里脊','土豆粉','鱼香肉丝', '烤肉拌饭', '麻辣香锅', '老碗面', '黄焖鸡', '羊肉烩面', '麻辣烫', '豆花鸡', '蛋包饭','大米'];
    var boxNode = document.getElementById("box");
    for (var i = 0; i < arrs.length; i++) {
      var divNode = document.createElement("div");
      divNode.innerHTML = arrs[i];
      divNode.className = "name";
      boxNode.appendChild(divNode);
    }
    var btn = document.getElementById("btn");
    btn.onclick = function () {
      if (this.value === "点击") {
        timeId = setInterval(function () {
          for (var j = 0; j < arrs.length; j++) {
            boxNode.children[j].style.background = "";
          }
          var random = parseInt(Math.random() * arrs.length);
          boxNode.children[random].style.background = "orange";
        }, 100);
        this.value = "停止";
      } else {
        clearInterval(timeId);
        this.value = "点击";
      }
    }
  </script>
</body>

</html>